import { message } from 'antd';
export default {
  namespace: 'produce',

  state: {
    workingInfo: [], // 服务器上的用户信息
    btnStartClicked: false, // 按钮是否被按下
    errorInfo: '无提示消息', // 自动作业过程中的错误提示框
    errorInfoModalVisble: false, // 自动作业过程中的错误提示框是否展示
    totalBoardSrc: null, // 展示totalBoardSrc的原图
    totalBoardErrorModalVisible: false, // totalBoardError提示框是否显示
    totalBoardErrorInfo: '无提示消息', // totalBoardError的提示消息
    boardSize: [0, 0], // 计算的板的尺寸
    inputSize: [0, 0], // 录入的尺寸
    boardCalcError: [0, 0], //识别误差
    boardSizeCheckModalVisible: false, // 尺寸确认框是否显示
    boardSizeHandLabelModalVisible: false, // 内板尺寸标注确认框
    handLabelSize: [0, 0], // 标注的尺寸
    labelBoardSizeMm: [0, 0], // 标注的尺寸mm
    cutLineCheckModalVisible: false, // 切线图确认框,可调整留边宽度
    calcResInfo: '', // 计算的结果信息
    isReturned: true, // 是否返回
    handAnnotatedModalVisble: false, // 标注两个内板的框是否显示
    labelTwoBoxSizeMm: [0, 0], // 标注两个内板的尺寸
    labelTwoBoxSizePix: [0, 0], // 标注两个内板在前端显示的尺寸,根据高宽比缩放了的尺寸
    handSixAnnotatedModalVisble: false,

    bigBeginCheckModalVisible: false, // 铡刀起点检测,有一个灯管全黑的显示框
    bigCutterImageSrc: null, //铡刀提示显示的图片,
    bigFontStart: false, // 铡刀那里的提示消息的颜色
    bigCutterHintInfo: '', // 铡刀那里的提示消息.
    bigFinalCheckModalVisible: false, // 铡刀终点检测提示框

    smallBeginCheckModalVisible: false, // 小铡刀起点检测显示框
    smallCutterImageSrc: null, // 小铡刀提示显示的图片,
    smallFontStart: '', // 小铡刀那里的提示消息的颜色
    smallCutterHintInfo: '', // 小铡刀那里的提示消息.
    smallFinalCheckModalVisible: false, // 小铡刀终点检测,错误提示框.

    produceStartModalVisible: false, // 设备启动提示框
    resetModalVisible: false, // 设备复位提示框
    produceStartModalInfo: '', // 设备启动提示框的内容
    resetModalInfo: '', // 复位提示框的内容.
    btnResetAllClicked: false, // 复位按钮是否被按下.
    cutLineSrc: null, // 切线图的图像源
    handTwoBoxesSrc: null, // 标注两个内板位置的图像源
    eapMsg: [], // 界面上要显示的EAP通信内容。
    cimMessage: '消息为空', // 远程消息提示内容
    cimMessageVisible: false, // 远程消息提示框是否存在
    userIdserver: '当前无用户使用', // 上下岗的用户ID
    userLogin: false, // 用户是否上岗
    loginHintVisible: false, // 员工上下岗提示框
    loginHint: '无信息', // 上下岗提示信息
    picErrorVisible: false, // 拍照是被提示是否显示
    picErrorMsg: '', // 拍照失败提示
    visibleDisplayStatus: false, //produceInfo信息提示框
    produceDisplayStatus: false, //produceInfo信息显示颜色
    produceInfo: '', //首板尺寸数据对比
  },

  // 和后台交互
  effects: {
    *handleProduceMessage({ payload }, { call, put }) {
      const { msg } = payload;
      if (msg.val === 'workingInfo') {
        yield put({
          type: 'getWorkingInfo',
        });
      } else if (msg.val == 'errorState') {
        yield put({
          type: 'updateErrorState',
          payload: [true, msg.errorInfo],
        });
      } else if (msg.val == 'totalBoardError') {
        yield put({
          type: 'updateTotalBoardErrorState',
          payload: [true, msg.totalBoardRes, msg.hintInfo],
        });
      } else if (msg.val == 'boardSizeCheck') {
        yield put({
          type: 'updateBoardSizeCheck',
          payload: [true, msg.boardRes, msg.boardSize, msg.inputSize, msg.boardCalcError],
        });
      } else if (msg.val == 'handBoardSize') {
        yield put({
          type: 'updateHandBoardSizeState',
          payload: [true, msg.upBoardRes, msg.labelBoardSize, msg.labelBoardSizeMm],
        });
      } else if (msg.val == 'cutLineCheck') {
        yield put({
          type: 'updateCutLineCheckState',
          payload: [true, msg.cutImage, msg.cutInfo],
        });
      } else if (msg.val == 'middleErrorCheck') {
        yield put({
          type: 'updateMiddleErrorCheck',
          payload: [true, msg.cutImage, msg.cutInfo],
        });
      } else if (msg.val == 'handAnnotated') {
        yield put({
          type: 'updateHandAnnotatedModalState',
          payload: [true, msg.totalBoard, msg.labelSizeMm, msg.labelSizePix, msg.cutInfo],
        });
      } else if (msg.val == 'handSixAnnotated') {
        yield put({
          type: 'updateHandSixAnnotatedModalState',
          payload: [true, msg.totalBoard, msg.labelSizeMm, msg.labelSizePix, msg.cutInfo],
        });
      } else if (msg.val == 'bigBeginCheckError') {
        yield put({
          type: 'updateBigBeginCheckErrorState',
          payload: [true, msg.bigCutterImageSrc, msg.bigCutterHintInfo],
        });
      } else if (msg.val == 'smallBeginCheckError') {
        yield put({
          type: 'updateSmallBeginCheckErrorState',
          payload: [true, msg.smallCutterImageSrc, msg.smallCutterHintInfo],
        });
      } else if (msg.val == 'frontFinalCheckError') {
        yield put({
          type: 'updateBigFinalCheckErrorState',
          payload: [true, msg.bigCutterImageSrc, msg.bigCutterHintInfo, msg.bigFontStart],
        });
      } else if (msg.val == 'smallFinalCheckError') {
        yield put({
          type: 'updateSmallFinalCheckErrorState',
          payload: [true, msg.smallCutterImageSrc, msg.smallCutterHintInfo, msg.smallFontStart],
        });
      } else if (msg.val == 'produceStartModal') {
        yield put({
          type: 'updateProduceStartModalState',
          payload: [msg.modalVisible, msg.produceStartInfo],
        });
      } else if (msg.val == 'resetAllModal') {
        yield put({
          type: 'updateResetModalState',
          payload: [msg.modalVisible, msg.resetInfo],
        });
      } else if (msg.val == 'displayStatus') {
        yield put({
          type: 'updateDisplayStatus',
          payload: [true, msg.displayStatus, msg.cutInfo],
        });
      } else if (msg.val == 'camZmcRsClearLineQueue') {
        yield put({
          type: 'clear_produce_line_queue',
          payload: [],
        });
      }
    },
    *testNewFunction({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_reqeust_test_new_function', []);
    },
    *getCutLinesAfterEdgeChange({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_reqeust_get_cut_lines_after_edge_change',
        [payload]
      );
      yield put({
        type: 'waitReturn',
        payload: true,
      });
    },

    *clickCutBoard({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_reqeust_cut_board', [payload]);
    },

    *handInnerBoardSizeIsOk({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_hand_inner_board_size_is_ok',
        [payload]
      );
    },
    *adjustHandBoardSize({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_adjust_board_size', [
        payload,
      ]);
    },
    *adjustHandBoardSizeTwoBox({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_adjust_board_size_two_box',
        [payload]
      );
    },
    *saveHandLabelBoardSize({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_save_hand_label_size', [
        payload,
      ]);
    },
    *saveWorkingInfo({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'db', 'web_reqeust_save_working_info', [
        payload,
      ]);
      if (response[0] === 'ok') {
        message.success('保存成功!', 3);
      } else {
        message.error('保存失败,' + response[1], 5);
      }
      yield put({
        type: 'getWorkingInfo',
      });
    },

    *getWorkingInfo({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'db', 'web_request_get_working_info', []);
      yield put({
        type: 'updateWorkingInfo',
        payload: response,
      });
    },

    *clickStartProduce({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_start_produce', [payload]);
      yield put({
        type: 'updateStartProduceBtn',
        payload: false,
      });
      if (response === 'ok') {
        message.success('自动作业启动成功!', 3);
      } else {
        message.error('自动作业启动失败,' + response, 5);
      }
    },

    *clickStopProduce({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_stop_produce', []);
      if (response === 'ok') {
        message.success('自动作业停止指令下发成功!', 3);
      } else {
        message.error('自动作业停止失败,' + response, 5);
      }
    },
    *clickResetAll({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_reset_all', []);
      yield put({
        type: 'updateResetAllBtnClick',
        payload: false,
      });
      if (response === 'ok') {
        message.success('复位成功!', 3);
      } else {
      }
    },

    *boardBack({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_board_back', []);
      if (response === 'ok') {
        message.success('板回退指令下发成功!', 3);
      } else {
        message.error('板回退指令下发失败,' + response, 5);
      }
    },
    *reGetImageProduce({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_re_get_image', []);
      if (response === 'ok') {
        message.success('重新拍照指令下发成功!', 3);
      } else {
        message.error('重新拍照指令下发失败,' + response, 5);
      }
    },
    *totalBoardIsOk({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_total_board_is_ok', []);
    },
    *nextBoardRes({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_next_board_res', []);
    },
    *lastBoardRes({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_last_board_res', []);
    },
    *keepOkSize({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_first_keep_ok_size', []);
    },
    *handDisplayStatus({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_keep_ok_size', []);
    },
    *handInnerBoardSize({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_hand_inner_board_size', []);
    },
    *handLabelFourBoxes({ payload }, { call, put }) {
      const { box_01_info, box_02_info, box_03_info, box_04_info } = payload;
      const response = yield call(window.eel.run_py, 'ph', 'web_request_hand_label_four_boxes', [
        box_01_info,
        box_02_info,
        box_03_info,
        box_04_info,
      ]);
      if (response !== 'ok') {
        message.error(response, 5);
      } else {
        // 标注成功,更新按钮状态.
      }
    },
    *handLabelSixBoxes({ payload }, { call, put }) {
      const { box_01_info, box_02_info, box_03_info, box_04_info, box_05_info, box_06_info } = payload;
      const response = yield call(window.eel.run_py, 'ph', 'web_request_hand_label_six_boxes', [
        box_01_info,
        box_02_info,
        box_03_info,
        box_04_info,
        box_05_info,
        box_06_info,
      ]);
      if (response !== 'ok') {
        message.error(response, 5);
      } else {
        // 标注成功,更新按钮状态.
      }
    },

    *rehandLabelFourBoxes({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_re_hand_label_two_boxes',
        []
      );
    },
    *bigCutterBeginCheckAgain({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_begin_check_again_big',
        []
      );
    },
    *cutterBeginCheckAgainSmall({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_begin_check_again_small',
        []
      );
    },
    *bigCutterFinalCheckAgain({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_final_check_again_big',
        []
      );
    },
    *smallCutterFinalCheckAgain({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_final_check_again_small',
        []
      );
    },

    *beginCheckManualOkSmall({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_begin_check_manual_ok_small',
        []
      );
    },
    *bigCutterFinalCutBoard({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_final_cut_board_big',
        []
      );
    },
    *smallCutterFinalCutBoard({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_final_cut_board_small',
        []
      );
    },
    *closeProduceStartModal({ payload }, { call, put }) {
      const response = yield call(
        window.eel.run_py,
        'ph',
        'web_request_close_produce_start_modal',
        []
      );
    },

    *clickResetCutterSelf({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_reset_big_cutter_self', []);
    },
    *backClickResetCutterSelf({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_reset_small_cutter_self', []);
    },
    *clickChangeOrder({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_change_order', [payload]);
      if (response === 'ok') {
        message.success('更换工单成功!', 3);
      } else {
        message.error(response, 5);
      }
    },
    *reCalcFirstBoard({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_re_calc_first_board', []);
      if (response === 'ok') {
        let msg = '重新做首板设置成功,下一块将走做首板的逻辑';
        message.success(msg, 3);
      } else {
        message.error('切换失败', 3);
      }
    },
    *disableCalcImage({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_disable_calc_image', [
        payload,
      ]);
      if (response === 'ok') {
        let msg = '切换成功';
        message.success(msg, 3);
      } else {
        message.error('切换失败', 3);
      }
    },
    *openCutterFinalCheckDir({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'open_cutter_final_check_dir', []);
      if (response === 'ok') {
        let msg = '打开成功';
        message.success(msg, 3);
      } else {
        message.error('打开失败', 3);
      }
    },

    *putBoardToCache({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_put_board_to_cache', []);
      if (response === 'ok') {
        message.success("下发放到缓存台指令成功!", 3);
      } else {
        message.error('下发放到缓存台指令失败!' + response, 3);
      }
    },

    *openCutterFinalResDir({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'open_cutter_final_res_dir', []);
      if (response === 'ok') {
        let msg = '打开成功';
        message.success(msg, 3);
      } else {
        message.error('打开失败', 3);
      }
    },
    *bigCutterBeginManualOk({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_begin_check_manual_ok_big', []);
    },
    *setOperaProcedureStart({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_set_opera_procedure_start', [payload]);
      if (response === 0) {
        let msg = '更换机械手状态成功！';
        message.success(msg, 3);
      } else {
        let msg = '更换机械手状态失败！';
        message.error(msg, 3);
      }
    },
    *webRequestUpdateCutDeep({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_request_cut_deep', []);
      if (response === 'ok') {
        let msg = 'succeed';
        message.success(msg, 5);
      } else {
        message.error('fail', 5);
      }
    },
    *clear_produce_line_queue({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'ph', 'web_reqeust_clear_line_queue', []);
    },
    *English_chinese_switching({ payload }, { call, put }) {
      const response = yield call(window.eel.run_py, 'cp', 'English_chinese_switching', [payload]);
    },
  },

  // 状态更新
  reducers: {
    waitReturn(state, action) {
      return {
        ...state,
        isReturned: action.payload,
      };
    },
    updateResetAllBtnClick(state, action) {
      return {
        ...state,
        btnResetAllClicked: action.payload,
      };
    },
    closeTotalModal(state, action) {
      return {
        ...state,
        errorInfoModalVisble: false,
        totalBoardErrorModalVisible: false,
        totalBoardSrc: null,
        cutLineSrc: null,
        handTwoBoxesSrc: null,
        totalBoardErrorInfo: '无提示消息',
        cutLineCheckModalVisible: false,
        boardSizeHandLabelModalVisible: false,
        handAnnotatedModalVisble: false,
        middleErrorCheckModalVisible: false,
        handSixAnnotatedModalVisble: false,
      };
    },
    bigCloseCutterCheckModal(state, action) {
      return {
        ...state,
        bigFinalCheckModalVisible: false,
        bigBeginCheckModalVisible: false,
        bigCutterImageSrc: null,
        bigCutterHintInfo: '',
      };
    },
    closeSmallCutterBeginCheckModal(state, action) {
      return {
        ...state,
        smallFinalCheckModalVisible: false,
        smallBeginCheckModalVisible: false,
        smallCutterImageSrc: null,
        smallCutterHintInfo: '',
      };
    },

    updateBigFinalCheckErrorState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        bigFinalCheckModalVisible: action.payload[0],
        bigCutterImageSrc: imgShow,
        bigCutterHintInfo: action.payload[2],
      };
    },
    updateSmallFinalCheckErrorState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        smallFinalCheckModalVisible: action.payload[0],
        smallCutterImageSrc: imgShow,
        smallCutterHintInfo: action.payload[2],
      };
    },
    updateBigBeginCheckErrorState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        bigBeginCheckModalVisible: action.payload[0],
        bigCutterImageSrc: imgShow,
        bigCutterHintInfo: action.payload[2],
      };
    },
    updateSmallBeginCheckErrorState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        smallBeginCheckModalVisible: action.payload[0],
        smallCutterImageSrc: imgShow,
        smallCutterHintInfo: action.payload[2],
      };
    },

    clearLabelTwoBoxesModalState(state, action) {
      return {
        ...state,
        handAnnotatedModalVisble: false,
        handSixAnnotatedModalVisble: false,
        handTwoBoxesSrc: null,
        labelTwoBoxSizeMm: (0, 0),
        labelTwoBoxSizePix: (0, 0),
        calcResInfo: '',
        middleErrorCheckModalVisible: false, // 中缝错误,需要放到缓存台的板子
      };
    },

    updateHandAnnotatedModalState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        handAnnotatedModalVisble: action.payload[0],
        handTwoBoxesSrc: imgShow,
        labelTwoBoxSizeMm: action.payload[2],
        labelTwoBoxSizePix: action.payload[3],
        calcResInfo: action.payload[4],
      };
    },
    updateHandSixAnnotatedModalState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        handSixAnnotatedModalVisble: action.payload[0],
        handTwoBoxesSrc: imgShow,
        labelTwoBoxSizeMm: action.payload[2],
        labelTwoBoxSizePix: action.payload[3],
        calcResInfo: action.payload[4],
      };
    },

    updateCutLineCheckState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        cutLineCheckModalVisible: action.payload[0],
        cutLineSrc: imgShow,
        calcResInfo: action.payload[2],
      };
    },
    updateMiddleErrorCheck(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        middleErrorCheckModalVisible: action.payload[0],
        cutLineSrc: imgShow,
        calcResInfo: action.payload[2],
      };
    },

    colseCutLineModal(state, action) {
      return {
        ...state,
        cutLineCheckModalVisible: false,
        cutLineSrc: null,
        calcResInfo: '',
      };
    },

    updateHandBoardSizeState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        boardSizeHandLabelModalVisible: action.payload[0],
        totalBoardSrc: imgShow,
        handLabelSize: action.payload[2],
        labelBoardSizeMm: action.payload[3],
      };
    },
    clearHandBoardSizeState(state, action) {
      return {
        ...state,
        boardSizeHandLabelModalVisible: false,
        totalBoardSrc: null,
        handLabelSize: [0, 0],
        labelBoardSizeMm: [0, 0],
      };
    },
    clearBoardSizeCheckModal(state, action) {
      return {
        ...state,
        boardSizeCheckModalVisible: false,
        totalBoardSrc: null,
        boardSize: [0, 0],
        inputSize: [0, 0],
        boardCalcError: [0, 0],
      };
    },
    updateBoardSizeCheck(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }
      return {
        ...state,
        boardSizeCheckModalVisible: action.payload[0],
        totalBoardSrc: imgShow,
        boardSize: action.payload[2],
        inputSize: action.payload[3],
        boardCalcError: action.payload[4],
      };
    },
    updateTotalBoardErrorState(state, action) {
      let imgShow;
      if (action.payload[1] != null) {
        imgShow = 'data:image/jpeg;base64,' + action.payload[1];
      } else {
        imgShow = null;
      }

      return {
        ...state,
        totalBoardErrorModalVisible: action.payload[0],
        totalBoardSrc: imgShow,
        totalBoardErrorInfo: action.payload[2],
      };
    },
    updateWorkingInfo(state, action) {
      return {
        ...state,
        workingInfo: action.payload,
      };
    },

    updateStartProduceBtn(state, action) {
      return {
        ...state,
        btnStartClicked: action.payload,
      };
    },
    updateProduceStartModalState(state, action) {
      return {
        ...state,
        produceStartModalVisible: action.payload[0],
        produceStartModalInfo: action.payload[1],
      };
    },
    updateResetModalState(state, action) {
      return {
        ...state,
        resetModalVisible: action.payload[0],
        resetModalInfo: action.payload[1],
      };
    },

    updateErrorState(state, action) {
      return {
        ...state,
        errorInfoModalVisble: action.payload[0],
        errorInfo: action.payload[1],
      };
    },
    closeErrorInfoModal(state, action) {
      return {
        ...state,
        errorInfoModalVisble: false,
        errorInfo: '',
      };
    },
    updateDisplayStatus(state, action) {
      return {
        ...state,
        visibleDisplayStatus: action.payload[0],
        produceDisplayStatus: action.payload[1],
        produceInfo: action.payload[2],
      };
    },
    closeDisplayStatus(state, action) {
      return {
        ...state,
        visibleDisplayStatus: false,
        produceDisplayStatus: false,
        produceInfo: '',
      };
    },
  },
};
